#include "playRecordParam.h"
#include "jsonUtils.h"

PlayRecordParam::PlayRecordParam() : id(0),dmId(0),test(0)
{
}

PlayRecordParam::PlayRecordParam(const int64_t& id, const int64_t& dmId, const int& test) : id(id),dmId(dmId),test(test)
{

}

String PlayRecordParam::jsonStr()
{
	JsonDoc doc(rapidjson::kObjectType);
	doc.AddMember(L"id", id, doc.GetAllocator());
	doc.AddMember(L"dmId", dmId, doc.GetAllocator());
	doc.AddMember(L"test", test, doc.GetAllocator());
	return JsonUtils::jsonStr(doc);
}

void PlayRecordParam::fromJson(const String& json)
{
	if (!json.empty()) {
		JsonDoc doc(rapidjson::kObjectType);
		doc.Parse(json.c_str());
		JsonUtils::loadLong(doc, L"id", id);
		JsonUtils::loadLong(doc, L"dmId", dmId);
		JsonUtils::loadInt(doc, L"test", test);
	}
}

const int64_t& PlayRecordParam::getId() const
{
	return id;
}

const int64_t& PlayRecordParam::getDmId() const
{
	return dmId;
}

const int& PlayRecordParam::getTest() const
{
	return test;
}
